<!doctype html>
<html lang="en">
<head>
<title>设备维修</title>

<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="设备维修">
<meta name="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<script src="../../script/js/echart/js/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../script/js/layui/css/layui.css" media="all">
<script type="text/javascript" src="../../script/js/layui/layui.js"></script>
<script type="text/javascript" src="../../mes/js/vue.min.js"></script>
<script type="text/javascript" src="../../mes/js/vue-resource.min.js"></script>
</head>

<body id="production">
<form class="layui-form layui-form-pane">
 <fieldset class="layui-elem-field layui-field-title">
  <legend><font color="white">待维修设备选择</font></legend>
			<div class="layui-form-item">
				<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;"><span class="layui-badge-dot layui-bg-orange" style="margin-right: 10px;"></span>待维修编码</label> 
						<div class="layui-input-inline" style="width:330px;">
							<select name="modules" lay-verify="required" lay-search="" lay-filter="processId">
								<option value="">直接选择或搜索选择</option>
								<option v-for="sel in sels" value="{{sel.CODE}}">{{sel.CODE}}——{{sel.NAME}}</option>
							</select>
						</div>
				</div>
				
				<div class="layui-inline">
					<label class="layui-form-label" style="width:160px;"> 设备编码：</label>
					<div class="layui-input-inline" style="width:230px;">
						<input type="text" id="" class="layui-input" v-model="manuOrder.CODE" disabled="" >
					</div>
				</div>
				<input type="hidden" v-model="manuOrder.CODE" id="epcode">
			</div>
	</fieldset>		
			
			
  <fieldset class="layui-elem-field layui-field-title" id='window1'>
  <legend><font color="white">待维修设备信息</font></legend>
			<div class="layui-form-item">
				<div class="layui-form-item" >
					<div class="layui-inline">
						<label class="layui-form-label" style="width:160px;color:gray;"> 设备名称：</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" v-model="manuOrder.NAME" disabled="" style="width:200px;color:gray;" >
						</div>
					</div>
			
					<div class="layui-inline">
						<label class="layui-form-label" style="width:160px;color:gray;"> 是否停机：</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" v-model="manuOrder.TYPES" disabled="" style="width:200px;color:gray;" id="resulttype" >
						</div>
					</div>
				
					<div class="layui-inline">
						<label class="layui-form-label" style="width:160px;color:gray;"> 车间：</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" v-model="manuOrder.BZNAME" disabled="" style="width:200px;color:gray;">
						</div>
					</div>
					
					
				</div>
				
				<div class="layui-form-item" >
					<div class="layui-inline">
						<label class="layui-form-label" style="width:160px;color:gray;"> 设备责任人：</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" v-model="manuOrder.YHNAME" disabled="" style="width:200px;color:gray;">
						</div>
					</div>
				
					<div class="layui-inline">
						<label class="layui-form-label" style="width:160px;color:gray;"> 报修人：</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" v-model="manuOrder.BXNAME" disabled="" style="width:200px;color:gray;">
						</div>
						<input type="hidden" v-model="manuOrder.BXUSERID" id="bxuserid">
					</div>
				
					<div class="layui-inline">
						<label class="layui-form-label" style="width:160px;color:gray;"> 报修时间：</label>
						<div class="layui-input-inline">
							<input type="text" class="layui-input" v-model="manuOrder.BXTIME" disabled="" style="width:200px;color:gray;">
						</div>
					</div>
				</div>
				
				<div class="layui-form-item" >
					<div class="layui-inline">
						<label class="layui-form-label" style="width:160px;height:90px;color:gray;"> 报修说明：</label>
						<div class="layui-input-inline">
							<textarea rows="50" cols="3" class="layui-input" v-model="manuOrder.REMARKS" disabled="" style="width:400px;height:90px;color:gray;" ></textarea>
						</div>
					</div>
				</div>
			</div>
	</fieldset>
	
	
	 <fieldset class="layui-elem-field layui-field-title" id='window2'>
  <legend><font color="white">故障分析及处理</font></legend>
	  	<div id = 'lastresultId'>
  				<div class="layui-form-item" >
  					<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;height:40px;"><span class="layui-badge-dot layui-bg-orange" style="margin-right: 10px;"></span>责任单位：</label>
						<div class="layui-input-inline" style="width:400px;height:40px;">
							<input type='text' id='orgname' name='username' lay-verify='required' placeholder='请输入' autocomplete='off' class='layui-input' style="width:400px;height:40px;"></input>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;height:40px;"><span class="layui-badge-dot layui-bg-orange" style="margin-right: 10px;"></span>故障时长：</label>
						<div class="layui-input-inline" style="width:250px;height:40px;">
							<input type='text' id='repairtime' name='repairtime' lay-verify='required|allnumber' placeholder='请输入' autocomplete='off' class='layui-input' style="width:250px;height:40px;"></input>
						</div>
						<label class="layui-form-label" style="width:120px;height:40px;">分钟（min）</label>
					</div>
				</div>
  				<div class="layui-form-item" >
  					<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;height:90px;"><span class="layui-badge-dot layui-bg-orange" style="margin-right: 10px;"></span>故障原因：</label>
						<div class="layui-input-inline" style="width:400px;height:90px;">
							<textarea  id='gztypes' name='username' lay-verify='required' placeholder='请输入' autocomplete='off' class='layui-input'style="width:400px;height:90px;"></textarea>
						</div>
					</div>
				
					<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;height:90px;"><span class="layui-badge-dot layui-bg-orange" style="margin-right: 10px;"></span>处理方法：</label>
						<div class="layui-input-inline" style="width:400px;height:90px;">
							<textarea type='text' id='method' name='username' lay-verify='required' placeholder='请输入' autocomplete='off' class='layui-input'style="width:400px;height:90px;"></textarea>
						</div>
					</div>
				
					
				</div>
				<div class="layui-form-item" >
					
					<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;height:90px;"><span class="layui-badge-dot layui-bg-orange" style="margin-right: 10px;"></span>改善措施：</label>
						<div class="layui-input-inline" style="width:400px;height:90px;">
							<textarea type='text' id='Measures' name='username' lay-verify='required' placeholder='请输入' autocomplete='off' class='layui-input' style="width:400px;height:90px;"></textarea>
						</div>
					</div>
					
  					<div class="layui-inline">
						<label class="layui-form-label" style="width:130px;height:90px;"><span class="layui-badge-dot layui-bg-orange" style="margin-right: 10px;"></span>备注：</label>
						<div class="layui-input-inline" style="width:400px;height:90px;">
							<textarea type='text' id='Remarks' name='username' lay-verify='required' placeholder='请输入' autocomplete='off' class='layui-input' style="width:400px;height:90px;"></textarea>
						</div>
					</div>
				</div>
  		</div>
			
	</fieldset>	
	
	
			
			
			
			
	<div class="layui-form-item" id='window4'>
		<button type="button"  class="layui-btn" lay-filter="*" lay-submit>提交</button>
		&nbsp;&nbsp;&nbsp;
		<button type="button"  class="layui-btn" @click="reset">重置</button>
	</div>
</form>
	<script type="text/javascript">
    var vm = new Vue({
		el : "#production",
		data : {
			selected:'',
			shebeicode:'',
			sels:[],
			manuOrder:{}
		},
		init:function(){
			 var _self = this;
	       	 this.$nextTick(function() {
					this.$http.post("../../equipment/getEquipmentPlanRepairList",{},{emulateJSON: true}).then(function(res){
						if(res.ok){
							_self.sels = res.body.Repairs;
						}
						layui.use(['form'], function(){
							var form = layui.form;
							form.on('select(processId)', function(data){
								 _self.selected = data.value;
							         $.ajax({
									    url: "../../equipment/loadCollectionCheck.html",
									    type: 'POST',
									    async: false,
									    data: {
								           CODE:_self.selected
									      },
									    dataType: 'json',
										success: function(data) {
										   if(data.result){
										   
										   	  _self.manuOrder = data.Maintenance[0];
										   	  
										   	  
										   	  if(_self.manuOrder.STATUS == 'USE'){
										   	  	_self.manuOrder.STATUS = '正常'
										   	  }else if(_self.manuOrder.STATUS == 'FREE'){
										   	  	_self.manuOrder.STATUS = '封存'
										   	  }else if(_self.manuOrder.STATUS == 'STOP'){
										   	  	_self.manuOrder.STATUS = '报废'
										   	  }
										   	 
							                  form.render(); //这个很重要
							                // }
										   }else{
										       layer.msg("处理失败");
										   }
										}
									});
						   	});
						  	form.on('submit(*)', function(data){
						  		_self.$options.methods.saveProductionData(_self);
							  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
							});
						   	form.verify({
							  allnumber: [
							    /^[0-9]+\.?[0-9]*$/
							    ,'请填写数字'
							  ] 
							}); 
						});
					});
			 }); 
		},
		methods: {
			saveProductionData:function(_self){
				var Equipmenttype = "repair";
				
				var Epcode = document.getElementById("epcode").value;   //设备编码
				var gztypes1 = document.getElementById("gztypes").value;  //故障原因
				var method1 = document.getElementById("method").value;	//处理方法
				var Measures1 = document.getElementById("Measures").value;	//改善措施
				var orgname1 = document.getElementById("orgname").value;	//责任单位
				var  Remarks1 = document.getElementById("Remarks").value;	//备注 
				var  bxuserid = document.getElementById("bxuserid").value;	//报修人的AD_USER_ID
				var repairtime = $("#repairtime").val();
				if(_self.selected == ""){
					layer.msg("请选择一个计划编码");
				}else{		
					if(!repairtime||repairtime==""){
						return;
					}
					var data ={
						Equipmenttype : Equipmenttype,
						PLANCODE1:_self.selected,
						CODE1 : Epcode,
						gztypes1 : gztypes1,
						method1 : method1,
						Measures1 : Measures1,
						Remarks1 : Remarks1,
						orgname1 : orgname1 ,
						bxuserids : bxuserid,
                        repairName :_self.manuOrder.BXNAME,
                        repairtime : repairtime
					};
	            	 _self.$nextTick(function() {
	 					_self.$http.post("../../equipment/saveEquipmentRepairation",data,{emulateJSON: true}).then(function(res){
	 						if(res.ok){ 		
	 							_self.result = res.body.results;				
	 							
	 							if(_self.result == "false"){
	 								layer.msg("维修失败"); 				
	 							}else{
		 							layer.msg("维修成功");
		 							window.setTimeout(function() {
										window.location.reload();
							   		 }, 1000);
	 							}
	 							
	 						}else{
	 						   layer.msg("维修失败"); 	
	 						}			
	 					  	
	 			 		});
	 				}); 
				}	
			},
			reset:function(data){
				window.location.reload();
			}
		}
	});
    </script>
</body>
</html>
